#include("../../comm/FormHead.html")
<div id="main">
    <div style="margin: 10px">
        <form action="" class="layui-form" lay-filter="form">
            <input type="hidden" id="actions" name="actions" value="#(form.actions)">
            #(token??)

            <div class="layui-row">
                <div class="layui-col-md12">
                    <div class="layui-form-item">
                        <label class="layui-form-label">分类编号</label>

                        <div class="layui-input-inline" style="width:250px">
                            <input type="text" name="type_code" placeholder="请输入分类CODE" #(form.actions== 'EDIT'?'readonly':'')
                            lay-verify="type_code" value="#(type.type_code)" class="layui-input #(form.actions== 'EDIT'?'input-readonly':'')">
                        </div>
                        <div class="layui-form-mid layui-word-aux">*必填 不可修改</div>
                    </div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-md12">
                    <div class="layui-form-item">
                        <label class="layui-form-label">分类名称</label>

                        <div class="layui-input-inline" style="width:250px">
                            <input type="text" name="type_name" placeholder="请输入分类名称" lay-verify="required"
                                   value="#(type.type_name)" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-md12">
                    <div class="layui-form-item">
                        <label class="layui-form-label">显示顺序</label>

                        <div class="layui-input-inline" style="width:250px">
                            <input type="text" name="sindex" placeholder="请输入姓名" lay-verify="number"
                                   value="#(type.sindex)" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-md12">
                    <div class="layui-form-item">
                        <label class="layui-form-label">分类说明</label>

                        <div class="layui-input-block">
                            <textarea name="type_desc" placeholder="请输入内容" class="layui-textarea">#(type.type_desc)</textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="Submit1">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
<SCRIPT LANGUAGE="JavaScript">
    <!--
    var $ = layui.$;
    layui.use(['form', 'myTool'], function () {
        var form = layui.form;
        form.on('submit(Submit1)', function (data) {
            layui.myTool.post("ModifySystemTypeDataApi", {postdata: JSON.stringify(data.field)}, function () {
                parent.layer.closeAll();
            });
            return false;
        });

        //较验code
        form.verify({
            type_code: function (value, item) {
                if ($("#actions").val() == 'EDIT') {

                    return '';
                } else if (value == '') {
                    return '请输入分类CODE';
                } else {
                    var checkResult = "";
                    $.ajax({
                        type: 'GET',
                        url: "CheckTypeCodeApi",
                        async: false,
                        data: {type_code: value},
                        success: function (results) {
                            if (results.code == 9) {
                                checkResult = "分类CODE已存在";
                            }
                        },
                        error: function (return_data) {
                        },
                        dataType: "json"
                    });
                    return checkResult;
                }
            }
        });
    });
    //-->
</SCRIPT>
</body>
</html>